IF OBJECT_ID('ssf.job_parse_jobstep_run_id') IS NOT NULL
	DROP FUNCTION ssf.job_parse_jobstep_run_id
GO

CREATE FUNCTION ssf.job_parse_jobstep_run_id (
	@jobstep_run_id XML
)
RETURNS TABLE
AS
/*
<object_header>

<object_summary>
	<purpose><![CDATA[

	]]></purpose>
</object_summary>

</object_header>
*/

	RETURN (
		SELECT jobstep_run_id.value('(/jobstep_run_id/@job_name)[1]', 'NVARCHAR(128)') AS job_name
			, jobstep_run_id.value('(/jobstep_run_id/@jobstep_id)[1]', 'INT') AS jobstep_id
			, jobstep_run_id.value('(/jobstep_run_id/@jobstep_start_datetime)[1]', 'DATETIME') AS jobstep_start_datetime
			, jobstep_run_id.value('(/jobstep_run_id/@parent_job_name)[1]', 'NVARCHAR(128)') AS parent_job_name
			, jobstep_run_id.value('(/jobstep_run_id/@parent_job_start_datetime)[1]', 'DATETIME') AS parent_job_start_datetime
			, jobstep_run_id.value('(/jobstep_run_id/@jobstep_spid)[1]', 'INT') AS jobstep_spid
		FROM (
			SELECT @jobstep_run_id AS jobstep_run_id
		) a
	)
GO
